import { _decorator, Component, Node, ColliderComponent, ITriggerEvent } from 'cc';
import { OBJ_TYPE } from '../../constant';
import { boss_aoe } from './boss_aoe';
import { boss_aoeBomb } from './boss_aoeBomb';
import { FireBall } from './fireBall';
const { ccclass, property } = _decorator;

@ccclass('flySkillCollider')
//只跟建筑物碰撞
export class flySkillCollider extends Component {
    private _colliderCom: ColliderComponent = null!;//

    public myType:OBJ_TYPE=null
    start() {

    }
    onEnable() {

        if(this.myType==OBJ_TYPE.friendly){
            return
        }else{
           // console.log("是敌人的投石器");
            
        }
        this._colliderCom.on("onTriggerEnter", this._onTriggerEnterCb, this);

    }
    private _onTriggerEnterCb(event: ITriggerEvent) {
        
        if(this.myType==OBJ_TYPE.friendly){
            return
        }else{
           // console.log("是敌人的投石器2");
        }

        const ts: FireBall = this.node.getComponent(FireBall)
        const ts2: boss_aoe = this.node.getComponent(boss_aoe)
        if (ts) {
          
            ts.bomb()
            return
        }
        if (ts2) {
          
            ts2.bomb()
            return
        }





    }
    onDestroy() {
        this._colliderCom.off("onTriggerEnter", this._onTriggerEnterCb, this);

    }
    onLoad() {

        this._colliderCom = this.node.getComponent(ColliderComponent) as ColliderComponent;
    }
    update(deltaTime: number) {

    }
}


